load("//test:regression.bzl", "regression_test")

# From CMakeLists.txt or_integration_tests(TESTS
COMPULSORY_TESTS = [
    "add_double_global_connection",
    "asap7_failed_macro_grid",
    "asap7_no_via_generate",
    "asap7_no_via_generate_v1_snapped",
    "asap7_offcenter_via",
    "asap7_taper",
    "asap7_vias",
    "asap7_vias_arrayspacing",
    "asap7_vias_arrayspacing_3_layer",
    "asap7_vias_arrayspacing_notfirst",
    "asap7_vias_arrayspacing_partial",
    "asap7_vias_cutclass",
    "asap7_vias_dont_use",
    "asap7_vias_fixed_vias",
    "asap7_vias_max_rows_columns",
    "asap7_M1_M3_followpins",
    "bpin_removal",
    "core_grid",
    "core_grid_adjacentcuts",
    "core_grid_auto_domain",
    "core_grid_auto_domain_multiple_nets",
    "core_grid_bad_metal_specs",
    "core_grid_check_connect_layers",
    "core_grid_cut_pitch",
    "core_grid_dual_followpins",
    "core_grid_dual_followpins_error",
    "core_grid_extend_to_boundary",
    "core_grid_extend_to_boundary_no_pins",
    "core_grid_failed_via_report",
    "core_grid_no_trim",
    "core_grid_obstruction",
    "core_grid_offset_strap",
    "core_grid_single_pin",
    "core_grid_snap",
    "core_grid_split_cuts",
    "core_grid_start_power",
    "core_grid_start_power_strap_ground",
    "core_grid_strap_count",
    "core_grid_via_snap",
    "core_grid_with_M6_min_area",
    "core_grid_with_M7_pins",
    "core_grid_with_dual_rings",
    "core_grid_with_fixed_pins",
    "core_grid_with_rings",
    "core_grid_with_rings_connect",
    "core_grid_with_rings_outside_die",
    "core_grid_with_rings_outside_die_allowed",
    "core_grid_with_rings_with_limit_straps",
    "core_grid_with_rings_with_straps",
    "core_grid_with_rings_with_straps_rings_over_core",
    "core_grid_with_routing_obstructions",
    "core_grid_with_single_layer_rings",
    "design_width",
    "existing",
    "global_connect_with_dont_touch",
    "global_connect_with_dont_touch_warning",
    "macros",
    "macros_add_twice",
    "macro_channel_with_secondary_repair",
    "macros_channel_recursive_repair",
    "macros_cells",
    "macros_cells_dont_touch",
    "macros_cells_extend_boundary",
    "macros_cells_no_grid",
    "macros_cells_not_fixed",
    "macros_cells_orient",
    "macros_cells_overlapping_ports",
    "macros_cells_via_failure",
    "macros_different_nets",
    "macros_grid_through",
    "macros_grid_through_without_middle",
    "macros_narrow_channel",
    "macros_narrow_channel_jog",
    "macros_narrow_channel_large_spacing",
    "macros_narrow_channel_overlap",
    "macros_narrow_channel_repair_overlap",
    "macros_with_halo",
    "macros_with_rings",
    "max_width",
    "min_spacing",
    "min_width",
    "names",
    "offgrid",
    "pads_black_parrot",
    "pads_black_parrot_flipchip",
    "pads_black_parrot_flipchip_connect_bumps",
    "pads_black_parrot_flipchip_connect_overpads",
    "pads_black_parrot_limit_connect",
    "pads_black_parrot_max_width",
    "pads_black_parrot_no_connect",
    "pads_black_parrot_offset",
    "power_switch",
    "power_switch_cut_rows",
    "power_switch_daisy",
    "power_switch_regions",
    "power_switch_star",
    "power_switch_upf_daisy",
    "power_switch_upf_error",
    "power_switch_upf_regions",
    "power_switch_upf_star",
    "region_non_rect",
    "region_secondary_nets",
    "region_temp_sensor",
    "region_temp_sensor_different_region_name",
    "repair_channel_inf_loop",
    "repair_vias",
    "report",
    "reset",
    "ripup",
    "sky130_spm_floating_bpin",
    "sroute_test",
    "widthtable",
]

# Disabled in CMakeLists.txt
MANUAL_TESTS = [
    "pdn_man_tcl_check",
    "pdn_readme_msgs_check",
]

ALL_TESTS = COMPULSORY_TESTS + MANUAL_TESTS

filegroup(
    name = "regression_resources",
    # Dependencies could be specified more narrowly per test case,
    # but at least it is not a glob of everything and there are
    # per test glob patterns below.
    srcs = [
        "Nangate45/Nangate45.lef",
        "Nangate45/Nangate45.pdn.tcl",
        "Nangate45/Nangate45.rc",
        "Nangate45/Nangate45.rcx_rules",
        "Nangate45/Nangate45.tracks",
        "Nangate45/Nangate45.vars",
        "Nangate45/Nangate45_fast.lib",
        "Nangate45/Nangate45_lvt.lef",
        "Nangate45/Nangate45_lvt.lib",
        "Nangate45/Nangate45_slow.lib",
        "Nangate45/Nangate45_stdcell.lef",
        "Nangate45/Nangate45_tech.lef",
        "Nangate45/Nangate45_typ.lib",
        "Nangate45/fake_macros.lef",
        "Nangate45/fake_macros.lib",
        "Nangate45/fakeram45.cfg",
        "Nangate45/fakeram45_1024x32.lef",
        "Nangate45/fakeram45_1024x32.lib",
        "Nangate45/fakeram45_256x16.lef",
        "Nangate45/fakeram45_256x16.lib",
        "Nangate45/fakeram45_512x64.lef",
        "Nangate45/fakeram45_512x64.lib",
        "Nangate45/fakeram45_64x32.lef",
        "Nangate45/fakeram45_64x32.lib",
        "Nangate45/fakeram45_64x7.lef",
        "Nangate45/fakeram45_64x7.lib",
        "Nangate45/fakeram45_64x96.lef",
        "Nangate45/fakeram45_64x96.lib",
        "Nangate45/work_around_yosys/cells.v",
        "Nangate45_vias/Nangate45_adjacentcuts.lef",
        "asap7_data/fakeram7_256x32.lef",
        "asap7_vias/asap7_tech_1x.lef",
        "asap7_vias/asap7_tech_1x_arrayspacing.lef",
        "asap7_vias/asap7_tech_1x_arrayspacing_tightspacing.lef",
        "asap7_vias/asap7_tech_1x_noviarules.lef",
        "asap7_vias/asap7_tech_1x_offcenter_via.lef",
        "asap7_vias/asap7_tech_1x_via_dontuse.lef",
        "asap7_vias/asap7sc7p5t_27_R_1x.lef",
        "asap7_vias/floorplan.def",
        "asap7_vias/floorplan_repair.def",
        "helpers.tcl",
        "nangate_bsg_black_parrot/Nangate45_maxwidth.lef",
        "nangate_bsg_black_parrot/dummy_pads.lef",
        "nangate_bsg_black_parrot/dummy_pads_short.lef",
        "nangate_bsg_black_parrot/floorplan.def",
        "nangate_bsg_black_parrot/floorplan_flipchip.def",
        "nangate_bsg_black_parrot/floorplan_flipchip_nogrid.def",
        "nangate_bsg_black_parrot/floorplan_flipchip_short.def",
        "nangate_existing/floorplan.def",
        "nangate_gcd/floorplan.def",
        "nangate_gcd/floorplan_obstructions.def",
        "nangate_gcd/floorplan_with_grid.def",
        "nangate_macros/fakeram45_256x16.lef",
        "nangate_macros/fakeram45_32x64.lef",
        "nangate_macros/fakeram45_64x32.lef",
        "nangate_macros/fakeram45_64x32_overlapping_ports.lef",
        "nangate_macros/floorplan.def",
        "nangate_macros/floorplan_narrow.def",
        "nangate_macros/floorplan_orient.def",
        "nangate_macros/floorplan_partial_wire_on_macro.def",
        "nangate_macros/floorplan_very_narrow.def",
        "nangate_macros/floorplan_with_jog.def",
        "repair_channel_inf_loop/floorplan.def",
        "repair_channel_inf_loop/tech_macro.lef",
        "sky130_gcd/floorplan.def",
        "sky130_non_rect_region/HEADER.lef",
        "sky130_non_rect_region/SLC.lef",
        "sky130_non_rect_region/floorplan.def",
        "sky130_pll/floorplan.def",
        "sky130_pll/pll.lef",
        "sky130_pll/pll_openmiddle.lef",
        "sky130_power_switch/floorplan.def",
        "sky130_power_switch/floorplan_cut_rows.def",
        "sky130_power_switch/floorplan_regions.def",
        "sky130_power_switch/netlist.v",
        "sky130_power_switch/netlist_regions.v",
        "sky130_power_switch/power_switch.lef",
        "sky130_secondary_nets/LDO_COMPARATOR_LATCH.lef",
        "sky130_secondary_nets/PMOS.lef",
        "sky130_secondary_nets/PT_UNIT_CELL.lef",
        "sky130_secondary_nets/capacitor_test_nf.lef",
        "sky130_secondary_nets/floorplan.def",
        "sky130_secondary_nets/vref_gen_nmos_with_trim.lef",
        "sky130_spm/delayed_serial_adder.lef",
        "sky130_spm/floorplan.def",
        "sky130_temp_sensor/4_cts.def",
        "sky130_temp_sensor/HEADER.lef",
        "sky130_temp_sensor/SLC.lef",
        "sky130_temp_sensor/floorplan.def",
        "sky130_temp_sensor/srouteHEADER.lef",
        "sky130_temp_sensor/srouteSLC.lef",
        "sky130hd/sky130_fd_sc_hd__ff_n40C_1v95.lib",
        "sky130hd/sky130_fd_sc_hd__ss_n40C_1v40.lib",
        "sky130hd/sky130_fd_sc_hd__tt_025C_1v80.lib",
        "sky130hd/sky130_fd_sc_hd_merged.lef",
        "sky130hd/sky130hd.pdn.tcl",
        "sky130hd/sky130hd.rc",
        "sky130hd/sky130hd.rcx_rules",
        "sky130hd/sky130hd.tlef",
        "sky130hd/sky130hd.tracks",
        "sky130hd/sky130hd.vars",
        "sky130hd/sky130hd_multi_patterned.tlef",
        "sky130hd/sky130hd_std_cell.lef",
        "sky130hd/sky130hd_std_cell_vt.lef",
        "sky130hd/sky130hd_tt.lib",
        "sky130hd/sky130hd_vt.tlef",
        "sky130hd/work_around_yosys/formal_pdk.v",
        "sky130hvl/sky130_fd_sc_hvl.tlef",
        "sky130hvl/sky130_fd_sc_hvl_merged.lef"
    ],
)

[
    filegroup(
        name = test_name + "_resources",
        srcs = [":regression_resources"] + glob(
            [
                test_name + ".*",
            ],
        ) + {
            "core_grid_auto_domain": ["core_grid.defok"],
            "core_grid_with_rings_connect": ["core_grid_with_rings.defok"],
            "macros_channel_recursive_repair": [
                "ihp_ethmac/tech.lef",
                "ihp_ethmac/sg13g2.lef",
                "ihp_ethmac/RM_IHPSG13_1P_256x48_c2_bm_bist.lef",
                "ihp_ethmac/floorplan.def",
            ],
        }.get(test_name, []),
    )
    for test_name in ALL_TESTS
]

[
    regression_test(
        name = test_name,
        data = [":" + test_name + "_resources"],
        tags = [] if test_name in COMPULSORY_TESTS else ["manual"],
        visibility = ["//visibility:public"],
    )
    for test_name in ALL_TESTS
]
